﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Ex6.ParsingDouble
{
    class ParsingDouble
    {
        private static void ParseDouble(string input)
        {

            Double result = default(Double);
            try
            {
                input = input.Trim();
                input = input.Replace(',', '.');
                input = input.Replace(' ', ','); 

                NumberStyles styles = NumberStyles.Any;
                result = Double.Parse(input, styles, CultureInfo.InvariantCulture);
                Console.WriteLine(result);
            }
            catch (System.FormatException)
            {
                Console.WriteLine("Parsed string is not in the supported format!");
            }
        }

        static void Main(string[] args)
        {
            string value = "123 123 123,12";
            ParseDouble(value);
        }
    }
}
